<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<input type="hidden" name="organizations/organization[0]/sequence_no" value="1" >
<input type="hidden" name="organizations/organization[0]@submit_org" value="1" >
<input type="hidden" name="organizations/organization[0]/org_code" value="<x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/>" >
<input type="hidden" name="proposal/basic_info/has_clicked_zc" value="0" id="has_clicked_zc" />
<input type="hidden" name="proposal/basic_info/now_year" value="${year }" id="now_yearqhh" />

<c:set var="fzr_name"><x:out select="$xmlData/data/proposal/fzr_name" /></c:set>
<c:if test="${empty fzr_name }"><c:set var="fzr_name"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/zh_name" /></c:set></c:if>		
<c:set var="fzr_tel_work"><x:out select="$xmlData/data/proposal/fzr_tel" /></c:set>
<c:if test="${empty fzr_tel_work }"><c:set var="fzr_tel_work"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/tel_work" /></c:set></c:if>
<c:set var="fzr_position"><x:out select="$xmlData/data/proposal/fzr_position" /></c:set>
<c:if test="${empty fzr_position }"><c:set var="fzr_position"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/position" /></c:set></c:if>
		<c:set var="age"><x:out select="$xmlData/data/proposal/fzr_age" /></c:set>
<c:set var="fzr_mobile"><x:out select="$xmlData/data/proposal/fzr_mobile" /></c:set>
		<c:if test="${empty fzr_mobile }"><c:set var="fzr_mobile"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/mobile" /></c:set></c:if>
<c:set var="fzr_email"><x:out select="$xmlData/data/proposal/fzr_email" /></c:set>
		<c:if test="${empty fzr_email }"><c:set var="fzr_email"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/email" /></c:set></c:if>
<c:set var="prof_title_name"><x:out select="$xmlData/data/proposal/prof_title_name" /></c:set>
		<c:if test="${empty prof_title_name }"><c:set var="prof_title_name"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/prof_title_name" /></c:set></c:if>
<c:set var="prof_title_value"><x:out select="$xmlData/data/proposal/prof_title_value" /></c:set>
		<c:if test="${empty prof_title_value }"><c:set var="prof_title_value"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/prof_title_value" /></c:set></c:if>
		
	
	
<c:set var="fzr_card_code"><x:out select="$xmlData/data/proposal/fzr_card_code" /></c:set>
<c:if test="${empty fzr_card_code }">
	<c:set var="card_type_value"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/card_type_value" /></c:set>
	<c:if test="${card_type_value==1 }">
			<c:set var="fzr_card_code"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/card_code" /></c:set>
	</c:if>
	<c:if test="${card_type_value!=1 }">
			<c:set var="fzr_card_code"></c:set>
	</c:if>
</c:if>

<table class="t_css" width="100%" border="0" cellpadding="0"
	id="orgInfo1" cellspacing="1">
	<col width="10%"/>
	<col width="15%"/>
	<col width="30%"/>
	<col width="15%"/>
	<col width="30%"/>
	<tr>
		<td align="right" nowrap>单位名称：</td>
		<td colspan="4">&nbsp;<span name="proposal/basic_info/org_name"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/org_name" /></span>
		</td>
	</tr>
	<tr>
		<td align="right" nowrap><span class="color_red">*</span>单位性质：</td>
		<td colspan="2">
			<c:set var="unit_type_xtcxjh"><x:out select="$xmlData/data/proposal/basic_info/unit_type_xtcxjh_value" /></c:set>
			<cpt:select id="unit_type_xtcxjh"   key="unit_type_xtcxjh"  value="${unit_type_xtcxjh}" onChange="initControlValue(this.id);" style="width:100px;"></cpt:select>
			<input type="hidden" id="unit_type_xtcxjh_value" name="proposal/basic_info/unit_type_xtcxjh_value" class="required" value="${unit_type_xtcxjh}" label="单位性质">
			<input type="hidden" name="proposal/basic_info/unit_type_xtcxjh_name" value="<x:out select="$xmlData/data/proposal/basic_info/unit_type_xtcxjh_name" />">
		</td>
		<td align="right">法人代表：</td>
		<td>&nbsp;
		    <span name="proposal/basic_info/faren_name"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/faren_name" />
		    </span>
		</td>
	</tr>
	<tr>
		<td align="right">详细地址：</td>
		<td colspan="2">&nbsp;
		    <span name="proposal/basic_info/org_address"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/address" /></span>
		</td>
		<td align="right" >邮政编码：</td>
		<td >&nbsp;
		    <span name="proposal/basic_info/org_zip_code"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/zip_code" /></span>
		</td> 
	</tr>
	<tr>
		<td rowspan="4" align="center">项<br/>目<br/>负<br/>责<br/>人</td>
		<td align="right">姓    名：</td>
		<td>
			<span name="proposal/fzr_name" >${fzr_name }</span>
		
		<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
			<a href="###" class="Blue" style="text-decoration: none;" onclick="orgPsnDailu()">[&nbsp;设置&nbsp;]</a>
		</security:authorize>
		</td>
		<td align="right">职    务：</td>
		<td>
			<span name="proposal/fzr_position" >${fzr_position }</span>
		</td>
	</tr>
	
	<tr>
	<td align="right">年    龄：</td>
		<td>
		<span name="proposal/fzr_age" id="fzr_age">${age }</span>
		</td>
		<td align="right">身份证号：</td>
		<td>
			<span name="proposal/fzr_card_code" id="fzr_card_code">${fzr_card_code }</span>
		</td>
	</tr>
	
	<tr>
			<td align="right">电话号码：</td>
			<td>
				<span  name="proposal/fzr_tel" >${fzr_tel_work }</span>
			</td>
		<td align="right">职    称：</td>
		<td>
	    	<span name="proposal/prof_title_name">${prof_title_name }</span>
	    	<input type="hidden" name="proposal/prof_title_value" value="${prof_title_value }"/>
		</td>
	</tr>
	
	<tr>
		<td align="right">手    机：</td>
		<td>
				<span name="proposal/fzr_mobile" >${fzr_mobile }</span>
		</td>
		<td align="right">E-mail：</td>
		<td>
				<span name="proposal/fzr_email" >${fzr_email }</span>
		</td>
	</tr>	
	
	<tr>
		<td rowspan="2" align="center">项<br/>目<br/>联<br/>系<br/>人</td>
		<td align="right"><span class="color_red">*</span>姓    名：</td>
		<td>
			<input type="text" name="proposal/basic_info/lxr_name" maxlength="20" class="input_text required" label="项目联系人-->姓名" value="<x:out select="$xmlData/data/proposal/basic_info/lxr_name" />" />
		</td>
		<td align="right"><span class="color_red">*</span>联系电话：</td>
		<td>
			<input type="text" name="proposal/basic_info/lxr_work_tel" maxlength="20" class="input_text required" label="项目联系人-->联系电话" value="<x:out select="$xmlData/data/proposal/basic_info/lxr_work_tel" />" />
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>手机号码：</td>
		<td>
			<input type="text" name="proposal/basic_info/lxr_mobile" class="input_text required mobile" onfocus="InitInput.setNumber(this,11,0,0)"  maxlength="11"label="项目联系人-->手机号码" value="<x:out select="$xmlData/data/proposal/basic_info/lxr_mobile" />" />
		</td>
		<td align="right"><span class="color_red">*</span>电子邮箱：</td>
		<td>
				<input type="text" name="proposal/basic_info/lxr_email" class="input_text required email" maxlength="50" label="项目联系人-->电子邮箱" value="<x:out select="$xmlData/data/proposal/basic_info/lxr_email" />" />
		</td>
	</tr>
</table>
<br/>
<div class="t_bar">
<span class="color_red">*</span>合作单位
</div>
		<table  id="heisi_wangkun" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;table-layout: fixed;" >
			<col width="7%" />
			<col width="8%" />
			<col width="85%" />
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center" >选择</th>
						<th class="TblHead" align="center" >序号</th>
						<th class="TblHead" align="center" >单位名称</th> 
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none" align="center">
						<td align="center">
							<input type="radio" class="radiobutton" name="heisi_wangkun" >
						</td>
						<td align="center">
							<span name="heisi_wangkun|list[0]@seq_no" >[index]</span> 
						</td>
						<td align="center">
							<input type="text" name="heisi_wangkun|list[0]|content" label="单位名称" class=" required input_text " maxlength="50" style="width:80%"/>
						</td>
					</tr>
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/heisi_wangkun/list" var="list">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr align="center">
						<td align="center">
							<input type="radio" class="radiobutton" name="heisi_wangkun" >
						</td>
						<td align="center">
							<span name="heisi_wangkun/list[${flag}${index}]@seq_no" ><x:out select="$list/@seq_no"/></span> 
						</td>
						<td align="center">
							<input type="text" name="heisi_wangkun/list[${flag}${index}]/content"  value="<x:out select="$list/content"/>"   label="单位名称" class=" required input_text " maxlength="50" style="width:80%"/>
						</td>
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					<script type="text/javascript">
						showAllDateTag("heisi_wangkun");
					</script>
				</tbody>
				</table>
		<table width="98%" align="center" border="0">
			<tr style="border: 0"><td style="border: 0">
			<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('heisi_wangkun',99,'合作单位最多只能添加99条')){addNewRow('heisi_wangkun');showDateTag('heisi_wangkun');try{top.resizeFrame();}catch(e){};}">
			<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('heisi_wangkun','heisi_wangkun')">
			<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('heisi_wangkun','heisi_wangkun')">
			<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('heisi_wangkun','合作单位');">
			</td></tr>
		</table>	
<script type="text/javascript">
$(document).ready(function() {
	/* if($("#prp_version").text()=='' || ($("#prp_version").text()!='' && $("#zh_prj_title").val()=='')){
		if($("#prof_title_hideId").val()==''){
			$("#prof_title_value_my").attr("class","required");
		}else{
			$("#prof_title_value_my").attr("class","");
		}
	}
	
	$("a[class='inputSelectButton']").click(function(){
		$("#prof_title_value_my").attr("class","required");
		$("#prof_title_value_my").val("");
		$("#prof_title_name_my").val("");
		$("#has_clicked_zc").val("1");
	}); */
	
	//初始化的时候计算年龄
	countAge($("#fzr_card_code").text(),$("#now_yearqhh").val());
});

function setShowOrHide(){
	var v=$("#unit_type_xtcxjh_value").val();
	//qiye_yfjf gx_yfjf kyjg_yfjf
	//class="input_text maxlength:20"
	if(v==1){
		$("#gx_yfjf").attr("class","input_text maxlength:20 ");
		$("#kyjg_yfjf").attr("class","input_text maxlength:20 ");
		
		$("#span_gx").text("");
		$("#span_kyjg").text("");
	}else if(v==2){
		$("#gx_yfjf").attr("class","input_text required maxlength:20 ");
		$("#kyjg_yfjf").attr("class","input_text maxlength:20 ");
		
		$("#span_gx").text("*");
		$("#span_kyjg").text("");
	}else if(v==3){
		$("#gx_yfjf").attr("class","input_text maxlength:20 ");
		$("#kyjg_yfjf").attr("class","input_text required  maxlength:20 ");
		
		$("#span_gx").text("");
		$("#span_kyjg").text("*");
	}
	
}

function countAge(id_card,now_year){
	//根据身份证号吗自动计算年龄
	if(checkCidInfo(id_card)){
		var year=id_card.substring(6,10);
		$("#fzr_age").text(now_year-year);
	}else{
		$("#fzr_age").text("");
	}
}

//校验身份证号码是否正确
function checkCidInfo(sId) {
	var iSum = 0;
	if (!/^\d{17}(\d|x)$/i.test(sId))
		return false;
	sId = sId.replace(/x$/i, "a");
	if (aCity[parseInt(sId.substr(0, 2))] == null)
		return false;
	sBirthday = sId.substr(6, 4) + "-" + Number(sId.substr(10, 2)) + "-"
			+ Number(sId.substr(12, 2));
	var d = new Date(sBirthday.replace(/-/g, "/"));
	if (sBirthday != (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d
			.getDate()))
		return false;
	for ( var i = 17; i >= 0; i--)
		iSum += (Math.pow(2, i) % 11) * parseInt(sId.charAt(17 - i), 11);
	if (iSum % 11 != 1)
		return false;
	return true;
}


function initTreeValueXtcxjh(treeId, treeNode) {
	$("#has_clicked_zc").val("1");
  	//针对单位性质
  	if (( treeNode && treeNode.isParent)) {
		scmWarn("请选择具体的"+$("#" + treeId).attr("label"));
			$("#" + treeId).val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val("");
			return false;
	}
		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			//str = obj.name + "-" + str;
			obj = obj.parentNode;
		}
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId + "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val(str);
		$("#" + treeId).val(str);
	}
	
//选择项目负责人回调
function selectPsnCall(data) {
	var position=data.personExtend.basic_info.position;
	if(position==undefined || position==null){
		position="";
	}
	$(parent.document).find("input[name$='psn_code']").val(data.person.psnCode);
	$("span[name='proposal/fzr_name']").text(data.person.zhName);
	$("span[name='proposal/fzr_position']").text(position);//职务
	if(data.person.cardType=='1'){
		$("span[name='proposal/fzr_card_code']").text(data.person.cardCode);
		countAge($("#fzr_card_code").text(),$("#now_yearqhh").val());
	}
	
	$("input[name='proposal/fzr_tel']").val(data.personExtend.contact.tel_work);
	$("span[name='proposal/prof_title_name']").text(data.person.profTitle);
	$("span[name='proposal/prof_title_value']").text(data.person.profTitleId);
	$("span[name='proposal/fzr_email']").text(data.personExtend.contact.email);
	$("input[name='proposal/fzr_mobile']").val(data.personExtend.contact.mobile);
	
	tb_remove2();
}

function orgPsnDailu() {
	var panCode=$("#psnCodeQhh").val();
	tb_show("编辑项目负责人信息",
			"${ctx}/proposal/sel-his-psn-gczxzj?psnCode="+panCode+"&TB_iframe=true&height=500&width=800",
			false);	
}
</script>